
<div style="clear: both;">
    <?php echo CHtml::beginForm('', 'post', array('class' => 'dot_form fw_50', 'enctype'=>'multipart/form-data')); ?>
    <fieldset>
        <legend><?php echo Yii::t('common', 'please_fill_table_contents'); ?></legend>
        <dl>
            <dt><?php echo CHtml::activeLabelEx($model, 'type'); ?></dt>
            <dd>
                <?php echo CHtml::activeDropDownList($model, 'type', Location::model()->typeOptions); ?>
            </dd>
            <dt><?php echo CHtml::activeLabelEx($model, 'name'); ?></dt>
            <dd>
                <div>
                    <?php
                    echo CHtml::activeTextField($model, 'name', array(
                        'maxlength' => 50,
                        'class' => 'small'
                    ));
                    ?>
                </div>
                <?php echo CHtml::error($model, 'name'); ?>
            </dd>
            <dt><?php echo CHtml::activeLabelEx($model, 'parent_id'); ?></dt>
            <dd>
                <?php
                $has_cache = Yii::app()->cache->get('cache_locations_tree_view_datas');
                if ($has_cache === false) {
                    require_once(Yii::app()->basePath . '/extensions/GraphTree/tree.php');
                    $datas = Location::model()->getCTreeViewDatas();
                    $datas = dumpArrayTree($datas);
                    $trees = array('1' => 'ΞΞ NODE ROOT ΞΞ');
                    if (count($datas)) {
                        foreach ($datas as $data) {
                            $trees[$data['id']] = $data['levelstr'] . '⇒ ' . strip_tags($data['text']) . '《' . (string)$data['order_pos'] . '》';
                        }
                    }
                    Yii::app()->cache->set('cache_locations_tree_view_datas', $trees, 1000);
                } else {
                    $trees = Yii::app()->cache->get('cache_locations_tree_view_datas');
                }
                echo CHtml::activeDropDownList($model, 'parent_id', $trees);
                ?>
            </dd>
            <dt><?php echo CHtml::activeLabelEx($model, 'order_pos'); ?></dt>
            <dd>
                <div>
                    <?php
                    echo CHtml::activeTextField($model, 'order_pos', array(
                        'maxlength' => 10,
                        'class' => 'small'
                    ));
                    ?>
                </div>
                <?php echo CHtml::error($model, 'order_pos'); ?>
            </dd>
            <dt></dt>
            <dd>
                <?php
                echo CHtml::submitButton($update
                    ? Yii::t('common', 'update') : Yii::t('common', 'save'), array(
                    'class' => 'btn'
                ));
                ?>
            </dd>
        </dl>
    </fieldset>
    <?php echo CHtml::endForm(); ?>
</div>